package com.meituan.service.impl;

import com.meituan.model.MerchantEntity;
import com.meituan.mapper.MerchantMapper;
import com.meituan.service.MerchantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class MerchantServiceImpl implements MerchantService {
    @Autowired
    MerchantMapper merchantMapper;

    @Override
    public MerchantEntity login(String merchantUsername, String merchantPassword) {
        return merchantMapper.findByMerchantUsernameAndMerchantPassword(merchantUsername,merchantPassword);
    }

    @Override
    public Integer register(MerchantEntity merchantEntity) {
        MerchantEntity result = merchantMapper.findByMerchantUsername(merchantEntity.getMerchantUsername());
        System.out.println(merchantEntity.getMerchantUsername());
        if(result!=null){
            return 0;
        }
        return merchantMapper.save(merchantEntity);
    }

}
